home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
c
/
vbccwos.lha
/
vbcc
/
doc
/
vbccppc.doc
< prev
next >
Wrap
Text File
|
1999-03-07
|
8KB
|
220 lines
vbcc - C compiler (c) in 1995-99 by Volker Barthelmann
INTRODUCTION
vbcc is a free portable and retargetable ANSI C compiler.
It is clearly split into a target independant and a target dependant
part and supports emulating datatypes of the target machine on any
other machine so that it is possible to e.g. make a crosscompiler for
a 64bit machine on a 32bit machine.
This document only deals with the target dependant parts of the
PowerPC version.
LEGAL
vbcc is (c) in 1995-99 by Volker Barthelmann. All code is written by me
and may be freely redistributed as long as no modifications are made
and nothing is charged for it.
Non-commercial usage of vbcc is allowed without any restrictions.
Commercial usage needs my written consent.
Sending me money, gifts, postcards etc. would of course be very nice
and may encourage further development of vbcc, but is not legally or
morally necessary to use vbcc.
ADDITIONAL OPTIONS FOR THIS VERSION
-merge-constants
Place identical floating point constants at the same
memory location. This can reduce program size and increase
compilation time.
-const-in-data
By default constant data will be placed in the .rodata
section. Using this option it will be placed in the data
section.
Note that on operating systems with memory protection this
option will disable write-protection of constant data.
-fsub-zero
Use fsub to load a floating-point-register with zero.
This is faster but requires all registers to always contain
valid values (i.e. no NaNs etc.) which may not be the case
depending on startup-code, libraries etc.
-amiga-align
Do not require any alignments greater than 2 bytes.
This is needed when accessing Amiga system-structures, but
can cause a performance penalty.
-elf
Do not prefix symbols with '_'. Prefix labels with '.'.
-poweropen
Generate code for the PowerOpen ABI like used in AIX.
This does not work correctly yet.
-sc
Generate code for the modified PowerOpen ABI used in the
StormC compiler.
-no-regnames
Do not use register names but only numbers. This is necessary
to avoid name-conflicts when using -elf.
-setccs
The V.4 ABI requires that when varargs-functions are called
with arguments passed in the floating-point registers this
has to be signalled in a certain bit of the condition code
register. vbcc usually doesn't make use of this and
therefore does not care about that bit by default.
This may lead to problems if you link objects compiled by
vbcc to objects not compiled by vbcc (e.g. a different
C-library) and call varargs-functions with floating-point
arguments.
In this case -setccs might help.
-peephole
Perform several peephole optimizations. Currently includes:
- better use of d16(r) addressing
- use of indexed addressing modes
- use of update-flag
- use of record-flag
- use of condition-code-registers to avoid certain branches
-use-lmw
Use lmw/stmw-instructions. This can significantly reduce
code-size. However these instructions may be slower on
certain PPCs.
SOME INTERNALS
The current version generates assembly output for use with the "pasm"
assembler by Frank Wille. The generated code should work on 32bit systems
based on a PowerPC CPU using the V.4 ABI.
The register names are:
r0 through r31 for the general purpose registers,
f0 through f31 for the floating point registers and
cr0 through cr7 for the condition-code registers.
The registers r0, r3-r12, f0-f13 and cr0-cr1 are used as scratch registers
(i.e. they can be destroyed in function calls), all other registers are
preserved. r1 is the stack-pointer and r13 is the small-data-pointer if
small-data-mode is used.
The first 8 function arguments which have integer or pointer types
are passed in registers r3 through r10 and the first 8 floating-point
arguments are passed in registers f1 through f8. All other arguments
are passed on the stack.
Integers and pointers are returned in r3, floats and doubles in f1.
All other types are returned by passing the function the address
of the result as a hidden argument - so when you call such a function
without a proper declaration in scope you can expect a crash.
The elementary data types are represented like:
type size in bits alignment in bytes (-amiga-align)
char 8 1 (1)
short 16 2 (2)
int 32 4 (2)
long 32 4 (2)
all pointers 32 4 (2)
float 32 4 (2)
double 64 8 (2)
TARGET-SPECIFIC VARIABLE ATTRIBUTES
The m68k-backend offers the following variable attributes:
__saveds: Load the pointer to the small data segment at
function-entry. Applicable only to functions.
__chip: Place variable in chip-memory. Only applicable on
AmigaOS to variables with static storage-duration.
__far: Do not place this variable in the small-data segment
in small-data-mode. No effect in large-data-mode.
Only applicable to variables with static storage-
duration.
__near: Currently ignored.
STDARG
A possible <stdarg.h> for V.4 ABI could look like this:
typedef struct {
int gpr;
int fpr;
char *regbase;
char *membase;
} va_list;
char *__va_start(void);
char *__va_regbase(void);
int __va_fixedgpr(void);
int __va_fixedfpr(void);
#define va_start(vl,dummy) \
( \
vl.gpr=__va_fixedgpr(), \
vl.fpr=__va_fixedfpr(), \
vl.regbase=__va_regbase(), \
vl.membase=__va_start() \
)
#define va_end(vl) (vl.regbase=vl.membase=0)
#define __va_size(type) ((sizeof(type)+3)/4*4)
#define va_arg(vl,type) \
(__typeof(type)&15)>8? \
(vl.membase+=__va_size(type),((type*)vl.membase)[-1]) \
: \
( \
(((__typeof(type)&15)==5||(__typeof(type)&15)==6)) ? \
( \
++vl.fpr<=8 ? \
((double*)(vl.regbase+32))[vl.fpr] \
: \
(vl.membase+=__va_size(type),((type*)vl.membase)[-1]) \
) \
: \
( \
++vl.gpr<=8 ? \
((int*)(vl.regbase+0))[vl.gpr] \
: \
(vl.membase+=__va_size(type),((type*)vl.membase)[-1]) \
) \
) \
KNOWN PROBLEMS
- composite types are put on the stack rather than passed via pointer
- indication of fp-register-args with bit 6 of cr is not done well
Volker Barthelmann volker@vb.franken.de